home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1990: Discy Business / Discy Business.2mg / DEV.CD / TOOLS / SAMPLES / HP / HP.ASM / PRINT.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-08-14  |  5.9 KB  |  251 lines  |  [B0] Apple IIgs Source Code (0x0003)

  1.  
  2. ******************************************************************************
  3. *                                                                            *
  4. *         HodgePodge:  An example Apple IIGS Desktop application             *
  5. *                                                                            *
  6. *         Written in 65816 Assembler by the Apple IIGS Tools Team            *
  7. *  Modified by Ben Koning for "Programmer's Introduction to the Apple IIGS"  *
  8. *                                                                            *
  9. *             Copyright (c) 1986-87 by Apple Computer, Inc.                  *
  10. *                                                                            *
  11. *   ----------------------------------------------------------------------   *
  12. *                                                                            *
  13. *    ASM65816 Code file "PRINT.ASM" -- Print dialogs; Print Manager calls    *
  14. *                                                                            *
  15. ******************************************************************************
  16.  
  17.  
  18.  
  19. ****************************************************************
  20. *
  21. * DoChooserItem
  22. *
  23. * This is the routine that handles the Choose Printer
  24. * menu item.
  25. *
  26. ****************************************************************
  27. DoChooserItem  START
  28.                using GlobalData
  29.  
  30.                PushWord #0
  31.                _PrChooser
  32.                pla
  33.  
  34.                rts
  35.  
  36.                END
  37.  
  38.  
  39.  
  40. ****************************************************************
  41. *
  42. * DoSetupItem
  43. *
  44. * This is the routine that handles the page setup item.
  45. *
  46. ****************************************************************
  47. DoSetupItem    START
  48.                using GlobalData
  49.  
  50.                lda PrintRecord
  51.                ora PrintRecord+2
  52.                bne AlreadyThere
  53.  
  54.                jsr SetupDefault
  55.  
  56. AlreadyThere   anop
  57.                pha
  58.                PushLong PrintRecord
  59.                _PrValidate
  60.                pla
  61.                Pushword #0
  62.                Pushlong PrintRecord
  63.                _prStlDialog
  64.                pla
  65.  
  66.                rts
  67.  
  68.                END
  69.  
  70.  
  71. ****************************************************************
  72. *
  73. * SetupDefault
  74. *
  75. * This routine creates the default PrintRecord.  Puts handle
  76. * in PrintRecord.
  77. *
  78. ****************************************************************
  79. SetupDefault   START
  80.                using GlobalDATA
  81.  
  82.                PushLong #0
  83.                PushLong #140
  84.                Pushword MyID
  85.                PushWord #$8010
  86.                PushLong #0
  87.                _newHandle
  88.                pla
  89.                sta PrintRecord
  90.                pla
  91.                sta PrintRecord+2
  92.  
  93. AlreadyThere   anop
  94.                PushLong PrintRecord
  95.                _prdefault
  96.  
  97.                rts
  98.  
  99.  
  100.                END
  101.  
  102. ****************************************************************
  103. *
  104. * DoPrintItem
  105. *
  106. * This is the routine that handles the print item in the
  107. * file menu.
  108. *
  109. ****************************************************************
  110. DoPrintItem    START
  111.                using GlobalData
  112.  
  113.                pha                      ; get the current port
  114.                pha
  115.                _GetPort
  116.  
  117.                pha                      ; first see if there is a window
  118.                pha                      ; to print.
  119.                _FrontWindow             ; and save pointer to it now
  120.                pla                      ; before any dialogs are displayed!
  121.                sta WindowToPrint
  122.                pla
  123.                sta WindowToPrint+2
  124.  
  125.                ora WindowToPrint
  126.                bne SomethingToPrint
  127.                brl SkipIt 
  128.  
  129. SomethingToPrint anop
  130.                lda PrintRecord
  131.                ora PrintRecord+2
  132.                bne AlreadySet
  133.  
  134.                jsr SetupDefault
  135.  
  136. AlreadySet     anop
  137.                PushLong PrintRecord
  138.                _PrValidate
  139.  
  140.  
  141.                PushWord #0
  142.                PushLong PrintRecord
  143.                _PrJobDialog
  144.                pla
  145.  
  146.                bne continue
  147.                brl skipit
  148.  
  149. continue       anop
  150.  
  151.                _WaitCursor
  152.  
  153.                PushLong #0
  154.                PushLong PrintRecord
  155.                PushLong #0
  156.                _PrOpenDoc
  157.                pla
  158.                sta PrintPort
  159.                pla
  160.                sta PrintPort+2
  161.  
  162.                PushLong PrintPort
  163.                PushLong #0
  164.                _PrOpenPage
  165.  
  166.                jsr DrawTopWindow
  167.  
  168.                PushLong PrintPort
  169.                _PrClosePage
  170.  
  171.                PushLong PrintPort
  172.                _PrCloseDoc
  173.  
  174.                PushLong PrintRecord
  175.                PushLong #0
  176.                PushLong #0
  177.                _PrPicFile
  178.  
  179.                _InitCursor
  180.  
  181. SkipIt         anop
  182.  
  183.                _SetPort                 ; restore original port
  184.  
  185.                rts
  186.  
  187.                END
  188.  
  189.  
  190. ****************************************************************
  191. *
  192. * DrawTopWindow
  193. *
  194. *
  195. *
  196. ****************************************************************
  197. DrawTopWindow  START
  198.                using GlobalDATA
  199.  
  200.                pha                      ; space for result of GetWRefCon call
  201.                pha
  202.                PushLong WindowToPrint
  203.                _GetWRefCon
  204.  
  205.                pla
  206.                sta TheRefCon
  207.                plx
  208.                stx TheRefCon+2
  209.                jsr Deref
  210.                sta 0
  211.                stx 2
  212.                ldy #oFlag
  213.                lda [0],y
  214.                beq UsePaint
  215.  
  216.  
  217.                ldy #oFontID+2
  218.                lda [0],y
  219.                tax
  220.                dey
  221.                dey
  222.                lda [0],y
  223.                jsl ShowFont
  224.  
  225.                bra AllDone
  226.  
  227. UsePaint       anop
  228.                ldy #oHandle+2           ; get handle to pic data
  229.                lda [0],y
  230.                tax
  231.                dey
  232.                dey
  233.                lda [0],y
  234.                jsl PaintIt
  235.  
  236.  
  237. AllDone        lda TheRefCon
  238.                ldx TheRefCon+2
  239.                jsr Unlock
  240.  
  241.                rts
  242.  
  243.  
  244. theRefCon      ds 4
  245.  
  246. WindowToPrint  ENTRY
  247.                ds 4
  248.  
  249.  
  250.                END
  251.